package com.demo.dao;

import com.demo.entity.operationLog;
import org.apache.ibatis.jdbc.SQL;

public class operationLogSqlProvider {

    public String insertSelective(operationLog record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("operation_log");
        
        if (record.getId() != null) {
            sql.VALUES("id", "#{id,jdbcType=VARCHAR}");
        }
        
        if (record.getType() != null) {
            sql.VALUES("type", "#{type,jdbcType=INTEGER}");
        }
        
        if (record.getObjectId() != null) {
            sql.VALUES("object_id", "#{objectId,jdbcType=VARCHAR}");
        }
        
        if (record.getUserId() != null) {
            sql.VALUES("user_id", "#{userId,jdbcType=VARCHAR}");
        }
        
        if (record.getOperationTime() != null) {
            sql.VALUES("operation_time", "#{operationTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getOperationResult() != null) {
            sql.VALUES("operation_result", "#{operationResult,jdbcType=VARCHAR}");
        }
        
        if (record.getNote() != null) {
            sql.VALUES("note", "#{note,jdbcType=VARCHAR}");
        }
        
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(operationLog record) {
        SQL sql = new SQL();
        sql.UPDATE("operation_log");
        
        if (record.getType() != null) {
            sql.SET("type = #{type,jdbcType=INTEGER}");
        }
        
        if (record.getObjectId() != null) {
            sql.SET("object_id = #{objectId,jdbcType=VARCHAR}");
        }
        
        if (record.getUserId() != null) {
            sql.SET("user_id = #{userId,jdbcType=VARCHAR}");
        }
        
        if (record.getOperationTime() != null) {
            sql.SET("operation_time = #{operationTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getOperationResult() != null) {
            sql.SET("operation_result = #{operationResult,jdbcType=VARCHAR}");
        }
        
        if (record.getNote() != null) {
            sql.SET("note = #{note,jdbcType=VARCHAR}");
        }
        
        sql.WHERE("id = #{id,jdbcType=VARCHAR}");
        
        return sql.toString();
    }
}